import { createBrowserRouter, Navigate } from "react-router-dom";
import Login from "../pages/Login";
import Layout from "../pages/Layout";
import Notfound from "../pages/Notfound";
import Index from "../pages/Index/index";
import DepartmentManagement from "../pages/HospitalComprehensive/DepartmentManagement";
import AddDepartment from "../pages/HospitalComprehensive/AddDepartment";
import DrugConsumption from "../pages/PatientData/DrugConsumption";
import DiseaseData from "../pages/PatientData/DiseaseData";
import RegistrationManagement from "../pages/DynamicPersonal/RegistrationManagement";
import MedicinePrescriptionManagement from "../pages/ChineseWesternMedicine/PrescriptionManagement";
import RevenueDataTable from "../pages/ChineseWesternMedicine/RevenueDataTable";
import MedicineStatistics from "../pages/ChineseWesternMedicine/MedicineStatistics.tsx";
import PrescriptionReceipts from "../pages/MedicalFrontline/PrescriptionReceipts";
import FrontlinePrescriptionManagement from "../pages/MedicalFrontline/PrescriptionManagement";
import MedicalEquipmentStatistics from "../pages/MedicalFrontline/MedicalEquipmentStatistics";
import DrugManage from "../pages/Drugs/DrugManage.tsx";
import DrugConsume from "../pages/Drugs/DrugConsume.tsx";
import DocScheduling from "../pages/Doctor/DocScheduling.tsx";
import DocEditInfo from "../pages/Doctor/DocEditInfo.tsx";
import DocList from "../pages/Doctor/DocList.tsx";
import NurseScheduling from "../pages/Nurse/NurseScheduling.tsx";
import NurseList from "../pages/Nurse/NurseList.tsx";
import NurseEditInfo from "../pages/Nurse/NurseEditInfo.tsx";
import SickbedManage from "../pages/Sickbed/SickbedManage.tsx";
import AddSickbed from "../pages/Sickbed/AddSickbed.tsx";
import AccManage from "../pages/AllAccount/AccManage.tsx";
import AddAccount from "../pages/AllAccount/AddAccount.tsx";
import EchartLayout from "../pages/EchartLayout.tsx";
import DepartmentEchart from "../pages/Echarts/DepartmentEchart.tsx";
import FinanceEchart from "../pages/Echarts/FinanceEcharts.tsx";
import OutpatientEchart from "../pages/Echarts/OutpatientEchart.tsx";
import {
  AppstoreFilled,
  BookFilled,
  SettingOutlined,
  HomeFilled,
  TagsFilled,
  ScheduleFilled,
  HddFilled,
  SignalFilled,
  SmileFilled,
  SkinFilled,
  ToolFilled,
} from "@ant-design/icons";

export const router = createBrowserRouter([
  {
    path: "/",
    element: <Layout />,
    children: [
      // 首页
      {
        index: true,
        title: "首页",
        icon: <HomeFilled style={{ color: "#FFF" }} />,
        element: <Index />,
      },
      // 医院综合
      {
        path: "hospital",
        title: "医院综合",
        meta: { role: "医生" },
        icon: <AppstoreFilled style={{ color: "#FFF" }} />,
        children: [
          {
            index: true,
            title: "科室管理",
            element: <DepartmentManagement />,
          },
          {
            path: "add",
            title: "添加科室",
            element: <AddDepartment />,
          },
        ],
      },
      // 患者大数据
      {
        path: "patient",
        title: "患者大数据",
        meta: { role: "医生" },
        icon: <BookFilled style={{ color: "#FFF" }} />,
        children: [
          {
            index: true,
            title: "药品耗材统计",
            element: <DrugConsumption />,
          },
          {
            path: "disease",
            title: "疾病大数据",
            element: <DiseaseData />,
          },
        ],
      },
      // 动态个人
      {
        path: "personal",
        title: "动态个人",
        meta: { role: ["护士", '实习助理','医生'] },
        icon: <TagsFilled style={{ color: "#FFF" }} />,
        children: [
          {
            index: true,
            title: "挂号管理",
            element: <RegistrationManagement />,
          },
        ],
      },
      // 中西医药房
      {
        path: "medicine",
        title: "中西医药房",
        meta: { role: "药房" },
        icon: <ScheduleFilled style={{ color: "#FFF" }} />,
        children: [
          {
            index: true,
            title: "处方综合管理",
            element: <MedicinePrescriptionManagement />,
          },
          {
            path: "revenue",
            title: "营收数据表",
            element: <RevenueDataTable />,
          },
          {
            path: "statistics",
            title: "药房统计",
            element: <MedicineStatistics />,
          },
        ],
      },
      // 医疗前线
      {
        path: "frontline",
        title: "医疗前线",
        meta: { role: "医生" },
        icon: <HddFilled style={{ color: "#FFF" }} />,
        children: [
          {
            index: true,
            title: "处方开具",
            element: <PrescriptionReceipts />,
          },
          {
            path: "management",
            title: "处方综合管理",
            element: <FrontlinePrescriptionManagement />,
          },
          {
            path: "statistics",
            title: "医疗器材统计",
            element: <MedicalEquipmentStatistics />,
          },
        ],
      },
      // 医疗药品出入库
      {
        path: "drugs",
        title: "医疗药品出入库",
        meta: { role: "药房" },
        icon: <SignalFilled style={{ color: "#FFF" }} />,
        children: [
          {
            index: true,
            title: "医疗用户综合管理",
            element: <DrugManage />,
          },
          {
            path: "consume",
            title: "添加药品耗材",
            element: <DrugConsume />,
          },
        ],
      },
      // 分级医生
      {
        path: "doctor",
        title: "分级医生",
        meta: { role: "医生" },
        icon: <SmileFilled style={{ color: "#FFF" }} />,
        children: [
          {
            index: true,
            title: "排班管理",
            element: <DocScheduling />,
          },
          {
            path: "docList",
            title: "综合列表",
            element: <DocList />,
          },
          {
            path: "docInfo",
            title: "修改个人信息",
            element: <DocEditInfo />,
          },
        ],
      },
      // 分级护士
      {
        path: "nurse",
        title: "分级护士",
        meta: { role: "护士" },
        icon: <SkinFilled style={{ color: "#FFF" }} />,
        children: [
          {
            index: true,
            title: "排班管理",
            element: <NurseScheduling />,
          },
          {
            path: "nurseList",
            title: "综合列表",
            element: <NurseList />,
          },
          {
            path: "nurseInfo",
            title: "修改个人信息",
            element: <NurseEditInfo />,
          },
        ],
      },
      // 病床管理
      {
        path: "sickbed",
        title: "病床管理",
        meta: { role: "护士" },
        icon: <SettingOutlined style={{ color: "#FFF" }} />,
        children: [
          {
            index: true,
            title: "添加床位",
            element: <AddSickbed />,
          },
          {
            path: "bedManage",
            title: "综合管理",
            element: <SickbedManage />,
          },
        ],
      },
      // 全账号管理
      {
        path: "allAcc",
        title: "全账号管理",
        icon: <ToolFilled style={{ color: "#FFF" }} />,
        children: [
          {
            index: true,
            title: "账号管理",
            element: <AccManage />,
          },
          {
            path: "addAcc",
            title: "添加账号",
            element: <AddAccount />,
          },
        ],
      },
    ],
  },
  {
    path: "/login",
    element: <Login />,
  },
  {
    path: "*",
    element: <Notfound />,
  },
  {
    path: "/echarts",
    element: <EchartLayout />,
    children: [
      {
        index: true,
        path:'index',
        title: '科室分析',
        element: <DepartmentEchart />
      },
      {
        path: "outpatient",
        title: "门诊分析",
        element: <OutpatientEchart />,
      },
      {
        path: "finance",
        title: "财务分析",
        element: <FinanceEchart />,
      },
      {
        path: '',
        element: <Navigate to="/echarts/index" />  // 这里进行重定向
      }
    ],
  },
]);

export default router;
